<template>
  <div>
    <div class="his-hot" v-if="isShowHistroy">
      <div class="hd">
        <h4>历史记录</h4>
        <van-icon name="delete-o" @click="delHistroy()" />
      </div>
      <div class="bd">
        <van-tag
          plain
          type="primary"
          text-color="#aaa"
          v-for="(item, index) in historyKeywordList"
          :key="index"
          @click="tagClick(item)"
          >{{ item }}</van-tag
        >
      </div>
    </div>

    <div class="his-hot">
      <div class="hd">
        <h4>热门搜索</h4>
      </div>
      <div class="bd">
        <van-tag
          plain
          :type="item.is_hot == 1 ? 'danger' : 'primary'"
          text-color="#aaa"
          v-for="(item, index) in hotKeywordList"
          :key="index"
          @click="tagClick(item.keyword)"
          >{{ item.keyword }}</van-tag
        >
      </div>
    </div>
  </div>
</template>

<script>
import { GetClearHistroyData } from "@/request/api";
export default {
  props: ["historyKeywordList", "hotKeywordList"],
  data() {
    return {
      isShowHistroy: true,
    };
  },
  methods: {
    // 点击tips标签，渲染内容
    tagClick(value) {
      console.log(value);
      this.$emit("tagClick", value);
    },
    // 清空历史记录
    delHistroy() {
      GetClearHistroyData().then((res) => {
        this.$toast("删除成功");
        setTimeout(() => {
          this.isShowHistroy = false;
        }, 1000);
      });
    },
  },
};
</script>
 
<style lang = "less" scoped>
.his-hot {
  background-color: #fff;
  padding: 0.1rem;
  margin-bottom: 0.2rem;
  .hd {
    display: flex;
    justify-content: space-between;
    font-size: 0.18rem;
  }
  .bd {
    margin-top: 0.15rem;
    /* margin-bottom: 0.05rem; */
    .van-tag {
      margin-right: 0.1rem;
      margin-bottom: 0.1rem;
    }
  }
}
.van-tag--danger.van-tag--plain {
  color: #ee0a24 !important;
  border-color: #ee0a24 !important;
}
</style>